import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../get/intl_keys.dart';
import 'build_detail_logic.dart';
import 'build_detail_state.dart';

class BuildDetailPage extends StatelessWidget {
  late BuildDetailLogic logic;
  late BuildDetailState state;

  BuildDetailPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    logic = Get.put(BuildDetailLogic());
    state = Get.find<BuildDetailLogic>().state;

    return Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: const Icon(
              Icons.navigate_before,
              size: 36,
            ),
            onPressed: () {
              Get.back();
            },
          ),
          centerTitle: true,
          title:const Image(image: AssetImage("images/logo.png"), width: 100.0),
          actions: [
            IconButton(
              ///icon: const Icon(Icons.person,size: 36,),
              icon:Image.asset("images/person.png"),
              onPressed: () {logic.goToSettingPage();},
            ),
          ],
        ),
        body: Container(
            width: double.infinity,
            height: double.infinity,
            decoration: const BoxDecoration(
              image: DecorationImage(
                image: AssetImage('images/app_bg.png'),
                fit: BoxFit.cover,
              ),
            ),
            child: Obx(() =>Container(
                margin: const EdgeInsets.fromLTRB(4, 4, 4, 10),
                color: const Color(0xFFE6E6E8),
                alignment: Alignment.topCenter,
                child:  SingleChildScrollView(
                  scrollDirection: Axis.vertical,
                  child:Column(
                    children: [
                      buildInfoView(context)
                    ],
                  ),
                )
            ))));
  }

  buildInfoView(BuildContext context) {
    return Container(
        margin: const EdgeInsets.fromLTRB(4, 10, 4, 10),
        alignment: Alignment.center,
        child:  Column(
          children: [
            Row(children: [
              Flexible(
                  flex: 1,
                  child: Column(
                    crossAxisAlignment:CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding: const EdgeInsets.fromLTRB(4, 0, 0, 0),
                        child: Text(IntlKeys.areaNo.tr,style: const TextStyle(fontSize: 20),),),
                      Container(
                          margin: const EdgeInsets.fromLTRB(4, 4, 4, 4),
                          alignment: Alignment.centerLeft,
                          constraints: const BoxConstraints(minHeight: 28),
                          decoration:BoxDecoration(
                              color: Colors.white,
                              border: Border.all(color: Colors.white,width: 1)
                          ),
                          child: Text("${state.buildDetail.value.getTag()}/${state.buildDetail.value.buildId}",style: const TextStyle(fontSize: 20)))
                    ],))
            ],),
            const SizedBox(height: 20,),
            Row(children: [
              Flexible(
                  flex: 1,
                  child: Column(
                    crossAxisAlignment:CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding: const EdgeInsets.fromLTRB(4, 0, 0, 0),
                        child: Text(IntlKeys.areaName.tr,style: const TextStyle(fontSize: 20),),),
                      Container(
                          margin: const EdgeInsets.fromLTRB(4, 4, 4, 4),
                          alignment: Alignment.centerLeft,
                          constraints: const BoxConstraints(minHeight: 28),
                          decoration:BoxDecoration(
                              color: Colors.white,
                              border: Border.all(color: Colors.white,width: 1)
                          ),
                          child: Text(logic.getBuildName(),style: const TextStyle(fontSize: 20)))
                    ],))
            ],),
            const SizedBox(height: 20,),
            Row(children: [
              Flexible(
                  flex: 1,
                  child: Column(
                    crossAxisAlignment:CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding: const EdgeInsets.fromLTRB(4, 0, 0, 0),
                        child: Text(IntlKeys.areaAddr.tr,style: const TextStyle(fontSize: 20),),),
                      Container(
                          margin: const EdgeInsets.fromLTRB(4, 4, 4, 4),
                          alignment: Alignment.centerLeft,
                          constraints: const BoxConstraints(minHeight: 28),
                          decoration:BoxDecoration(
                              color: Colors.white,
                              border: Border.all(color: Colors.white,width: 1)
                          ),
                          child: Text(logic.getBuildAddr(),style: const TextStyle(fontSize: 20)))
                    ],))
            ],),
            const SizedBox(height: 20,),
            Row(children: [
              Flexible(
                  flex: 1,
                  child: Column(
                    crossAxisAlignment:CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding: const EdgeInsets.fromLTRB(4, 0, 0, 0),
                        child: Text(IntlKeys.subName.tr,style: const TextStyle(fontSize: 20),),),
                      Container(
                          margin: const EdgeInsets.fromLTRB(4, 4, 4, 4),
                          alignment: Alignment.centerLeft,
                          constraints: const BoxConstraints(minHeight: 28),
                          decoration:BoxDecoration(
                              color: Colors.white,
                              border: Border.all(color: Colors.white,width: 1)
                          ),
                          child: Text(logic.getSubZone(),style: const TextStyle(fontSize: 20),))
                    ],)),
              Flexible(
                  flex: 1,
                  child: Column(
                    crossAxisAlignment:CrossAxisAlignment.start,
                    children: [
                      Padding(
                        padding: const EdgeInsets.fromLTRB(4, 0, 0, 0),
                        child: Text(IntlKeys.areaType.tr,style: const TextStyle(fontSize: 20),),),
                      Container(
                          margin: const EdgeInsets.fromLTRB(4, 4, 4, 4),
                          alignment: Alignment.centerLeft,
                          constraints: const BoxConstraints(minHeight: 28),
                          decoration:BoxDecoration(
                              color: Colors.white,
                              border: Border.all(color: Colors.white,width: 1)
                          ),
                          child: Text(logic.getSubName(),style: const TextStyle(fontSize: 20)))
                    ],))
            ],),
          ],
        )
    );
  }
}
